﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.Mvc;
using System.Security.Principal;
using System.Web.Security;
using Vmago.Models;
using Vmago.Models.DBML;

namespace Vmago.Controllers
{

    public class HomeController : ControllerBase
    {
        #region Gobal：私有变量

        private ViewDataContext m_oView = new ViewDataContext(); 

        #endregion

        #region Gobal：构造函数

        public HomeController()
        {
        }

        #endregion                

        #region Index：首页初始化

        /// <summary>Index页面初始化</summary>
        public ActionResult Index()
        {
            ViewData["Title"] = "go2jp匯璟网";
            ViewData["lbHead"] = "登录go2jp.com匯璟网帐户";
            ViewData["lbUsername"] = "用户名";
            ViewData["lbPassword"] = "密码";
            ViewData["lbRemindMe"] = "记住我";
            ViewData["lbLogin"] = "登录";
            ViewData["Date"] = System.DateTime.Now.ToLongDateString();

            List<vw_recArea> oRecCitys = m_oView.prc_shopRecCity(null, 4, 1).ToList();
            List<vw_recShop> oRecShops = new List<vw_recShop>();
            List<vw_recShop> oHotShops = m_oView.prc_shopPerformance("Top", null, 5).ToList();
            List<vw_searchRanking> oHotSearch = (from p in m_oView.vw_searchRanking
                                                 where p.ranking <= 5
                                                 select p).ToList();

            foreach (vw_recArea oRecCity in oRecCitys)
            {                
                IEnumerable<vw_recShop> oRecShops_ = m_oView.prc_shopRecShop(oRecCity.ID, null, null, null, null);
                foreach (vw_recShop oRecShop_ in oRecShops_)
                {  
                    oRecShops.Add(oRecShop_);
                }
            }

            ViewData["RecCity"] = oRecCitys;
            ViewData["RecShop"] = oRecShops;
            ViewData["HotShop"] = oHotShops;
            ViewData["HotSearch"] = oHotSearch;

            return View();
        }

        #endregion        

        #region LogingIndex：页面初始化

        public ActionResult LogingIndex()
        {
            return View();
        }

        #endregion

        #region MoreVideo：页面初始化

        public ActionResult MoreVideo(string id)
        {
            return View();
        }

        #endregion

        #region SearchMessage：页面初始化

        public ActionResult SearchMessage(string id)
        {
            if (Session["searchButton"] != null)
            {
                string searchMessage = Session["searchButton"].ToString();
                ViewData["searchString"] = searchMessage;
                Session.Remove("searchButton");
            }
            return View();
        }

        #endregion        

        #region Video：页面初始化

        public ActionResult Video(string id)
        {
            return View();
        }

        #endregion

        #region viewdatecityifram：

        public void viewdatecityifram(int Class, string Category, int Suburb)
        {
            int category = 0;
            if (Category == "first")
            {
                category = 2;
            }
            ViewData["ClassID"] = Class;
            ViewData["Category"] = category;
            ViewData["Sbuburb"] = Suburb;
            CityController cc = new CityController();
            cc.CityIfram(Class, category, Suburb);
        }

        #endregion        
    }
}
